﻿<Window x:Class="CncConvProg.View.Dialog.ToolsDialogView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Dialog="clr-namespace:CncConvProg.ViewModel.Dialog;assembly=CncConvProg.ViewModel" xmlns:MVVM_Library="clr-namespace:CncConvProg.ViewModel.MVVM_Library;assembly=CncConvProg.ViewModel" xmlns:ToolViewModels="clr-namespace:CncConvProg.ViewModel.CommonViewModel.ToolViewModels;assembly=CncConvProg.ViewModel" xmlns:ToolDataTemplate="clr-namespace:CncConvProg.View.Dialog.ToolDataTemplate" xmlns:ab="clr-namespace:CncConvProg.View.AttachedProperty" Title="Tools Dialog" MinHeight="600" MinWidth="600"
        WindowStyle="ToolWindow"
        WindowState="Normal"
        Width="1024"
        Height="768"
        WindowStartupLocation="CenterScreen"
        >
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="../Controls/AppStyle.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

    </Window.Resources>
    <Grid >
        <Grid.RowDefinitions>
            <RowDefinition Height="671*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="0.362*" MinWidth="150" />
            <ColumnDefinition Width="0.638*" MinWidth="150" />
        </Grid.ColumnDefinitions>

        <!-- Lista Utensili -->
        <Border x:Name="Colonna_SX" Grid.RowSpan="1">
            <DockPanel>
                <Menu Margin="10,5" DockPanel.Dock="Top" HorizontalAlignment="Left" >
                    <MenuItem Header="New Tool" >
                        <MenuItem.Icon>
                            <Image Source="pack://application:,,,/Images/gui/addPlus.png" Width="15"/>
                        </MenuItem.Icon>
                        <MenuItem Header="Drill Type">
                            <MenuItem Header="Drill" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Punta}"/>
                            <MenuItem Header="Tap" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Maschio}"/>
                            <MenuItem Header="Reamer" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Alesatore}"/>
                            <MenuItem Header="Bore" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Bareno}"/>
                            <MenuItem Header="Counterbore" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Lamatore}"/>
                            <MenuItem Header="Chamfer" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Svasatore}"/>
                            <MenuItem Header="Center Drill" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.Centrino}"/>
                        </MenuItem>
                        <MenuItem Header="Mill" >
                            <MenuItem Header="Flat Mill" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.FresaCandela}"/>
                            <MenuItem Header="Face Mill" Command="{Binding Path=NewToolCmd}"  CommandParameter="{x:Static Dialog:ToolTypeEnum.FresaSpianare}"/>
                        </MenuItem>
                    </MenuItem>
                </Menu>
                <TreeView ItemsSource="{Binding Path=TreeView}" Grid.Row="1" >
                    <TreeView.Resources>
                        <HierarchicalDataTemplate DataType="{x:Type ToolViewModels:ToolTreeViewItemViewModel}" ItemsSource="{Binding Children}" >
                            <Border  Margin="2,2,2,0" >
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Path=ToolDescription}" MinWidth="150"/>
                                    <Button Content="Del" Command="{Binding Path=DataContext.DelToolCmd, RelativeSource={RelativeSource AncestorLevel=1, AncestorType={x:Type Window}, Mode=FindAncestor}}"
                                            CommandParameter="{Binding}" />
                                </StackPanel>
                            </Border>
                        </HierarchicalDataTemplate>

                        <HierarchicalDataTemplate DataType="{x:Type Dialog:ToolTypeItemViewModel}" ItemsSource="{Binding Children}" >
                            <Border Margin="4,4,4,0" >
                                <StackPanel Orientation="Horizontal">
                                    <TextBlock Text="{Binding Path=Label}" FontSize="14" FontStyle="Italic"/>
                                </StackPanel>
                            </Border>
                        </HierarchicalDataTemplate>

                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="PowderBlue" />
                        <SolidColorBrush x:Key="{x:Static SystemColors.HighlightTextBrushKey}" Color="Black" />

                    </TreeView.Resources>
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}" />
                            <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                        </Style>
                    </TreeView.ItemContainerStyle>
                </TreeView>

            </DockPanel>
        </Border>

        <GridSplitter Width="2" Height="250"  />
        <!-- Dettagli Utensile -->
        <Border x:Name="Colonna_DX" Grid.Column="1" Margin="2,5,5,5" BorderThickness="2" Grid.RowSpan="1">

            <DockPanel>
                <TextBlock HorizontalAlignment="Left" DockPanel.Dock="Top"
                               Width="250" Text="{Binding Path=UtensileSelezionato.Descrizione}" FontSize="24" Margin="10,10,0,10" />
                <Grid >
                    <Grid.Resources>
                        <ResourceDictionary >
                            <ResourceDictionary.MergedDictionaries>
                                <ResourceDictionary  Source="pack://application:,,,/CncConvProg.View;component/Lavorazioni/OperazioneScreen/Common/OperazioneViewResources.xaml"/>
                            </ResourceDictionary.MergedDictionaries>
                        </ResourceDictionary>
                    </Grid.Resources>
                    <Grid.RowDefinitions>
                        <RowDefinition Height=".5*" />
                        <RowDefinition Height=".5*" />
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width=".5*" />
                        <ColumnDefinition Width=".5*" />
                    </Grid.ColumnDefinitions>

                    <ContentControl Grid.Row="3" Grid.Column="1"  Margin="5" Content="{Binding Path=UtensileSelezionato.ToolParameterViewModel}"/>

                    <StackPanel DockPanel.Dock="Top" Grid.Row="1" Grid.Column="0" >
                        <TextBlock Text="Material : " FontSize="20" />
                        <ComboBox ItemsSource="{Binding Path=Materiali}" 
                                SelectedItem="{Binding Path= MaterialeSelezionato}"
                                Height="40"   
                                Width="250"
                                Margin="2" 
                                HorizontalAlignment="Left">
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <Border Padding="2" Margin="2">
                                        <StackPanel Orientation="Horizontal">
                                            <Image Width="22" Height="22" Style="{StaticResource ResourceKey=ImageStyle}" />
                                            <TextBlock Text="{Binding Path=Descrizione}" VerticalAlignment="Center" Margin="3"/>
                                        </StackPanel>
                                    </Border>
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </StackPanel>

                    <GroupBox Header="Tool Detail" Margin="5" Grid.Row="0" Grid.Column="0" >
                        <ContentControl Content="{Binding Path=UtensileSelezionato}"/>
                    </GroupBox>
                </Grid>

            </DockPanel>
        </Border>

        <DockPanel Grid.Row="3"  Grid.ColumnSpan="2">
            <Button Background="AntiqueWhite" DockPanel.Dock="Left" Content="Reset Tool Store" HorizontalAlignment="Left" Height="19" FontStyle="Oblique" FontSize="10" Command="{Binding Path=ResetToolStoreCmd}"/>
            <StackPanel Orientation="Horizontal" HorizontalAlignment="Right" >
                <Button Content="Annulla" Width="100" Margin="5" Click="Button_Click_1" />
                <Button Content="Ok" Width="100" Margin="5" Click="Button_Click" />
            </StackPanel>
        </DockPanel>
    </Grid>
</Window>
